<%@ page import="java.sql.*" %>
<% Class.forName("com.mysql.jdbc.Driver");

 String url;
 Connection conn;
 ResultSet rs;
 Statement stmt;
 
%>


        <% 
    	try 
    	{
    		Class.forName("com.mysql.jdbc.Driver");
    		url = "jdbc:mysql://localhost/student_db";
    		conn = DriverManager.getConnection(url, "root", "");
    		
    		stmt = conn.createStatement();
    		rs = stmt.executeQuery("Select * from student");
    		
    		out.print("<table border=\"1\">");
    		
    		out.print("<tr>");
    		out.print("<td>");
    		out.print("NAME");
    		out.print("</td>");
    		out.print("<td>");
    		out.print("ADDRESS");
    		out.print("</td>");
    		out.print("<td>");
    		out.print("TEL #");
    		out.print("</td>");
    		out.print("<td>");
    		out.print("</td>");
    		out.print("<td>");
    		out.print("</td>");
    		out.print("</tr>");
    		
    		while(rs.next())
    		{
    			String id = rs.getObject(1).toString();
    			
    			out.print("<tr>");
    			out.print("<td>");
    			out.print(rs.getObject(2).toString());
    			out.print("</td>");
    			out.print("<td>");
    			out.print(rs.getObject(3).toString());
    			out.print("</td>");
    			out.print("<td>");
    			out.print(rs.getObject(4).toString());
    			out.print("</td>");
    			out.print("<td>");
    			out.print("<a href=\"http://localhost:8080/Student/DeleteStudent.jsp?id=" + id + "\">Delete</a>");
    			out.print("</td>");
    			out.print("<td>");
    			out.print("<a href=\"http://localhost:8080/Student/UpdateStudent.jsp?id=" + id + "\">Update</a>");
    			out.print("</td>");
    			out.print("</tr>");
    			
    		}
    		
    		out.print("</table>");
    		out.print("<a href=\"http://localhost:8080/Student/AddStudent.jsp\">Add New Student</a><br>");
   	
    	} 
    	catch (ClassNotFoundException cnfe) 
    	{
    			out.println("" + cnfe);
    	}
    	catch (SQLException sqle)
    	{
    			out.println("" + sqle);
    	}
       %>
